﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="market"
    targetNamespace="http://yahoofinance.codeplex.com/1/market.xsd"
    elementFormDefault="qualified"
    xmlns="http://yahoofinance.codeplex.com/1/market.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

  <xs:simpleType name="SectorID">
    <xs:restriction base="xs:int">
      <xs:minInclusive value="1"/>
      <xs:maxInclusive value="9"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="IndustryID">
    <xs:restriction base="xs:int">
      <xs:minInclusive value="100"/>
      <xs:maxInclusive value="999"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="CurrencyID">
    <xs:restriction base="xs:string">
      <xs:length value="3" fixed="true"></xs:length>
      <xs:pattern value="[A-Z][A-Z][A-Z]"></xs:pattern>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="CountryID">
    <xs:restriction base="xs:string">
      <xs:length value="2" fixed="true"></xs:length>
      <xs:pattern value="[A-Z][A-Z]"></xs:pattern>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="StockExchangeID">
    <xs:restriction base="xs:string">
      <xs:length value="3" fixed="true"></xs:length>
      <xs:pattern value="[A-Z][A-Z][A-Z]"></xs:pattern>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Suffix">
    <xs:restriction base="xs:string">
      <xs:pattern value="(\.[A-Z]*)?"></xs:pattern>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="IndexID">
    <xs:restriction base="xs:string">
      <xs:pattern value="\^?[A-Z0-9]*(\.[A-Z0-9]*)?"></xs:pattern>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="DelayMinutes">
    <xs:restriction base="xs:int">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="1440"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Day">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Mo"></xs:enumeration>
      <xs:enumeration value="Tu"></xs:enumeration>
      <xs:enumeration value="We"></xs:enumeration>
      <xs:enumeration value="Th"></xs:enumeration>
      <xs:enumeration value="Fr"></xs:enumeration>
      <xs:enumeration value="Sa"></xs:enumeration>
      <xs:enumeration value="Su"></xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  
  
  
  
  
  
  <xs:element name="WorldMarket">
    <xs:complexType>
      <xs:sequence>

        <xs:element name="Sectors">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Sector" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="SectorID" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Industries">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Industry" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="IndustryID" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Currencies">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Currency" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="CurrencyID" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Countries">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Country" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="CountryID" use="required"></xs:attribute>
                  <xs:attribute name="Currency" type="CurrencyID" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="StockExchanges">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="StockExchange" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    
                    <xs:element name="TradingTime">
                      <xs:complexType>
                        <xs:sequence>
                          
                          <xs:element name="TradingDays" minOccurs="0" maxOccurs="1" default="Mo Tu We Th Fr">
                            <xs:simpleType>
                              <xs:list itemType="Day">
                              </xs:list>
                            </xs:simpleType>
                          </xs:element>
                          
                          <xs:element name="NonTradingDays" minOccurs="0" maxOccurs="1">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="NonTradingDay" minOccurs="0" maxOccurs="unbounded">
                                  <xs:complexType>
                                    <xs:attribute name="Date" type="xs:date" use="required"></xs:attribute>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          
                        </xs:sequence>
                        <xs:attribute name="OpeningTimeLocal" type="xs:time" use="required"></xs:attribute>
                        <xs:attribute name="ClosingTimeLocal" type="xs:time" use="required"></xs:attribute>
                        <xs:attribute name="DelayMinutes" type="DelayMinutes" use="required"></xs:attribute>
                        <xs:attribute name="TimeZone" type="xs:string" use="required"></xs:attribute>
                      </xs:complexType>
                    </xs:element>
                    
                  </xs:sequence>
                  <xs:attribute name="ID" type="StockExchangeID" use="required"></xs:attribute>
                  <xs:attribute name="Country" type="CountryID" use="required"></xs:attribute>
                  <xs:attribute name="Suffix" type="Suffix" default="" use="optional"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                  <xs:attribute name="Location" type="xs:string" default="" use="optional"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Indices">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Index" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="IndexID" use="required"></xs:attribute>
                  <xs:attribute name="StockExchange" type="StockExchangeID" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="FundCategories">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Category" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="xs:string" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="FundFamilies">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Family" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="ID" type="xs:string" use="required"></xs:attribute>
                  <xs:attribute name="Name" type="xs:string" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>


        <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>

      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
